package com.tourlaid.mamagerment.action.wx

import com.tourlaid.mamagerment.ao.wx.PersonHomeAo
import com.tourlaid.mamagerment.entity.ResponseData
import com.tourlaid.mamagerment.vo.ThoughtVo
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.RestController

/**
 * Created by xiaoyongge on 2017/7/20.
 */
@RestController
@RequestMapping("/tld/admin/phome")
class PersonHomeAction {

    @Autowired
    val personHomeAo: PersonHomeAo? = null

    @RequestMapping("/getAttention.json")
    fun getAttention(targetUserId: Long): ResponseData<Int> {
        val isAttention = personHomeAo!!.getAttention(targetUserId);
        return ResponseData(isAttention)
    }

    /**
     * 关注
     */
    @RequestMapping("/attention.json")
    fun attention(targetUserId: Long): ResponseData<Int> {
        val isAttention = personHomeAo!!.attention(targetUserId);
        return ResponseData(isAttention)
    }

    /**
     * 取消关注
     */
    @RequestMapping("/cancelAttention.json")
    fun cancelAttention(targetUserId: Long): ResponseData<Int> {
        personHomeAo!!.cancelAttention(targetUserId);
        return ResponseData(0)
    }


    /**
     * 加载说说
     */
    @RequestMapping("/queryThought.json")
    fun queryThought(targetUserId: Long,
                     @RequestParam(defaultValue = "1") pageNo: Int): ResponseData<MutableList<ThoughtVo>> {
        var responseData = personHomeAo!!.queryThought(targetUserId, pageNo);
        return responseData
    }

    /**
     * 店迹
     */
    @RequestMapping("/queryTrace.json")
    fun queryTrace(targetUserId: Long): ResponseData<MutableList<MutableMap<String, String>>> {
        var mapList = personHomeAo!!.queryTrace(targetUserId);
        return ResponseData(mapList)
    }
}